<script setup lang="ts">
import { useAuth } from '@/biz/hooks/useAuth'
import { useRouter } from 'vue-router'
const { user, logoutFunc } = useAuth()
const router = useRouter()
const onClickLogOut = () => {
  logoutFunc()
  //跳转到登录页
  router.push({
    name: 'login'
  })
}
const onClickLogin = () => {
  router.push({
    name: 'login'
  })
}
</script>
<template>
  <div>
    <template v-if="user.id">
      已登录，用户为：{{ user.nickname }},点击这里：
      <div @click="onClickLogOut">退登</div>
    </template>
    <template v-else> <div @click="onClickLogin">请登录</div> </template>
  </div>
</template>
